﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<script type="text/javascript">
    if ($("#DispStr").val() != "") {
        var aa = $("#DispStr").val();
        strDispName = eval("(" + aa + ")");//显示名
    }

    function SearchSave(str) {
        disablesave(str);
        //获取右边数据
        var checked = [];
        $('.wrapR-c-box-b-right ul input').each(function () {
            var thisname = $(this).val();
            checked.push(thisname + "#" + getdispname(thisname));
        })
        var columnstr = "";
        if (checked != null && checked.length > 0) {
            columnstr = checked.toString();
        }
        else {
            messageAlert("请添加排序列！");
            enablesave(str);
            return;
        }
        var flage = "update";
        if (str == "next") {
            flage = "save";
        }

        $.ajax({
            type: "POST",
            url: "@Html.Raw(Url.Action("SortColumnSave", "Admin_SingleDBPublish"))",
            data: { "DbID": $("#DbID").val(), "Column": columnstr, "Flage": flage },
            success: function (msg) {
                if (msg == "True") {
                    if (str == "next") //下一步
                    {
                        var urlstr = "@Html.Raw(Url.Action("PublishOver", "Admin_SingleDBPublish"))";
                        var dataobj = { "DbID": $("#DbID").val() };
                        ajaxLoad("initload", urlstr, dataobj);
                    }
                    else {
                        messageAlert("操作成功！");
                    }
                }
                else {
                    messageAlert("操作失败！");
                }
                enablesave(str);
            },
            error: function (e)
            { enablesave(str); }
        })
    }

    function disablesave(str) {
        if (str == 'save') {
            $(".btn-warn-f").attr("disabled", "disabled");
        }
    }
    function enablesave(str) {
        if (str == 'save') {
            $(".btn-warn-f").removeAttr("disabled", "disabled");
        }
    }
</script>
<!-- wrapRStart -->

<div class="wrapR-h">
    @if (ViewBag.PubFlage == 1)
    {
        <h3 style="color:red">修改模式下可以点选下列菜单进行字段设置</h3>
    }
    <ul class="step step-line-4 clearfix">


        @if (ViewBag.PubFlage == 1)//修改时允许点击
        {

            
            <li class="next"><a onclick="jumpPage('@Html.Raw(Url.Action("Config", "Admin_SingleDBPublish"))')">发布形式设置</a>  </li>
            <li class="next"><a onclick="jumpPage('@Html.Raw(Url.Action("SearchColumn", "Admin_SingleDBPublish"))')">检索字段</a></li>
            <li class="next"><a onclick="jumpPage('@Html.Raw(Url.Action("ViewColumn", "Admin_SingleDBPublish"))')">概览字段</a></li>
            <li class="next"><a onclick="jumpPage('@Html.Raw(Url.Action("DetialColumn", "Admin_SingleDBPublish"))')">细览字段</a></li>
            <li class="done cur"><a onclick="jumpPage('@Html.Raw(Url.Action("SortColumn", "Admin_SingleDBPublish"))')">排序字段</a></li>
        }
        else //发布
        {
            <li class="next">发布形式设置</li>
            <li class="next">检索字段</li>
            <li class="next">概览字段</li>
            <li class="next">细览字段</li>
            <li class="next cur">排序字段</li>
            <li class="done">发布完成</li>
        }
    </ul>


</div>

<div class="wrapR-c wrapR-c2">
    <div class="clearfix posr wrapR-c2-in">
        <div class="wrapR-c-box wrapR-c-l fl posr" style="overflow-y: visible">
            <div class="wrapR-c-box-t">数据库字段</div>
            <div class="wrapR-c-box-b-left" style="overflow-y: scroll; height: 380px">
                <ul>
                    @{
                        if (ViewBag.ListField != null)
                        {
                            foreach (SYS_CMS_DATABASE_FIELD item in ViewBag.ListField)
                            {
                                int obser = 0;
                                string dispname = item.Field;
                                if (!item.Field.Trim().StartsWith("SYS_FLD_"))
                                {
                                    obser = 1;
                                }
                                else if (item.Field.Trim() == "SYS_FLD_DOWNLOADRATE")
                                {
                                    obser = 1;
                                    dispname = "下载量";

                                }
                                else if (item.Field.Trim() == "SYS_FLD_SYSID")
                                {
                                    obser = 1;
                                    dispname = "记录号";

                                }
                                else if (item.Field.Trim() == "SYS_FLD_BROWSERATE")
                                {
                                    obser = 1;
                                    dispname = "浏览量";

                                }
                                if (obser == 1)
                                {
                        <li class="f-ct">
                            <label class="f-label block">
                                <input type="checkbox" class="f-checkboxL" onclick="leftcheck(this)" value='@item.Field' />@dispname</label>

                        </li>
                                }
                            }

                        }
                    }
                </ul>
                <div class="f-ct wrapR-c-box-footer posa">
                    <label class="f-label ml10">
                        <input type="checkbox" class="f-checkbox-left" onclick="leftCheckAll(this)" />全选</label>
                </div>
            </div>

        </div>
        <div class="wrapR-c-m tc posa"><a class="iconfont-s iconfont-right-triangle-s" onclick="rightMove('.wrapR-c-box-b-left','.wrapR-c-box-b-right')"></a></div>
        <div class="fr posr">
            <div class='wrapR-c-box wrapR-c-r wrapR-c-r-l' style="overflow-y: visible">
                <div class="wrapR-c-box-t">排序项</div>
                <div class="wrapR-c-box-b-right" style="overflow-y: scroll; height: 380px">
                    <ul class="ulfield">
                        @if (ViewBag.DiapList != null)//修改时加载已经设置的字段
                        {
                            foreach (SYS_CMS_DATABASE_PUBLISH_FIELD item in ViewBag.DiapList)
                            {
                                string dispnamestr = item.FieldName;
                                if (item.FieldName.Trim() == "SYS_FLD_DOWNLOADRATE")
                                {
                                    dispnamestr = "下载量";

                                }
                                else if (item.FieldName.Trim() == "SYS_FLD_SYSID")
                                {
                                    dispnamestr = "记录号";

                                }
                                if (item.FieldName.Trim() == "SYS_FLD_BROWSERATE")
                                {
                                    dispnamestr = "浏览量";

                                }
                            <li class="f-ct">
                                <label class="f-label block">
                                    <input type="checkbox" class="f-checkboxR" onclick="inputclickright(this)" value='@item.FieldName' />@dispnamestr</label>

                            </li>
                            }
                        }
                    </ul>
                    <div class="f-ct wrapR-c-box-footer posa clearfix">
                        <label class="f-label ml10 fl">
                            <input type="checkbox" class="f-checkbox-right" onclick="rightCheckAll(this)">全选</label>
                        <a class="btn btn-s btn-warn-f fr deleteright" onclick="deleteright()">删除</a>
                    </div>
                </div>
            </div>

            <div class="wrapR-c-r-r form-h posa" style="top: 10px">
                <div style="padding-bottom: 50px">
                  <a title="移至最顶部" onclick=" movefirst(this)" class="iconfont-s iconfont-upest-s"></a>
                    <br />
                    <a title="上移" onclick="moveablove(this)" class="iconfont-s iconfont-up-s"></a>
                    <br />
                    <a title="下移" onclick="movedown(this)" class="iconfont-s iconfont-down-s"></a>
                    <br />
                    <a title="移至最底部" onclick="movelast(this)" class="iconfont-s iconfont-downest-s"></a>
                </div>
                <div class="wrapR-c-r-r-t">字段显示名设置</div>
                <div class="f-gp">
                    <div class="f-lb">
                        <label class="f-label">字段名：</label>
                    </div>
                    <div class="f-ct f-ml">
                        <input type="text" id="rewritename" placeholder="" class="f-text f-text-plh" readonly="true">
                        <input type="hidden" id="realname" class="f-text f-text-plh">
                    </div>
                </div>

                <div class="f-gp">
                    <div class="f-lb">
                        <label class="f-label">显示名：</label>
                    </div>
                    <div class="f-ct f-ml">
                        <input type="text" id="displayname" value="" class="f-text f-text-plh" maxlength="32">
                    </div>
                </div>
                <div class="f-gp" style="display: none">
                    <div class="f-lb">
                        <label class="f-label">宽度：</label>
                    </div>
                    <div class="f-ct f-ml">
                        <input type="text" id="displaywidth" value="" class="f-text f-text-plh" style="width: 50px;display:none" maxlength="2">%
                    </div>
                </div>

                <div class="f-gp">
                    <div class="f-lb">
                        <label class="f-label"></label>
                    </div>
                    <div class="f-ct f-ml">
                        <a class="btn btn-warn-f" href="javascript:void(0);" onclick="saveDispName()">保存设置</a>
                    </div>
                </div>

            </div>
        </div>
    </div>

    @*<p class='mt10'>提示：关联库设置后，允许当前数据库通过某字段链接到其他数据库，例如：论文库中的作者字段，可链接至学者库中查看作者详细信息。</p>*@
    <div class="tc mt30">
        @if (ViewBag.PubFlage == 0)
        {
            <a class="btn btn-m btn-submit btn-prim-f" href="javascript:void(0);" onclick="ajaxLoad('initload', '@Html.Raw(Url.Action("DetialColumn", "Admin_SingleDBPublish"))?DbID=@ViewBag.DbID');">上一步</a>
            <a class="btn btn-m btn-submit btn-prim-f" href="javascript:void(0);" onclick="SearchSave('next')">下一步</a>
        }
        else
        {
          
            <button class="btn btn-m btn-prim-f" onclick="ajaxLoad('initload','@Html.Raw(Url.Action("Index", "Admin_SingleDBPublish"))');">返回</button>
          <button class="btn btn-m btn-submit btn-warn-f" style="margin-left:30px;"  onclick="SearchSave('save')">保存</button>
        }
    </div>
    <input type="hidden" id="DbID" name="DbID" value="@ViewBag.DbID" />
    <input type="hidden" id="DispStr" name="DispStr" value="@ViewBag.DispName" />
</div>
<!-- wrapREnd -->
